package com.gadarts.parashoot.enemies;

import java.util.ArrayList;

import android.graphics.Bitmap;
import android.graphics.Rect;

import com.gadarts.parashoot.GameModel;
import com.gadarts.parashoot.GameView;
import com.gadarts.parashoot.Sprite;
import com.gadarts.parashoot.utils.C;
import com.gadarts.parashoot.utils.Utils;

public class Infantry extends SoldierEnemy {

	public Infantry(GameModel model, GameView view, ArrayList<Sprite> sprites,
			int x, int y, int speed, int direction, int depth, int health,
			boolean fitFrameToDirection, Bitmap bodyPart) {
		super(model, view, sprites, x, y, speed, direction, depth, health,
				fitFrameToDirection, bodyPart);
		super.setChild(this);
		setAnimation(C.Enemies.Paratroopers.Infantry.ANIMATION_SPEED,
				C.Enemies.Paratroopers.Infantry.ANIMATION_TIMER_NAME, false,
				false);

		int parachuteBottom = C.Enemies.Paratroopers.Infantry.PARACHUTE_BOTTOM;
		Sprite sprite = sprites
				.get(C.Enemies.Paratroopers.Infantry.SINKING_SPRITE_INDEX);
		Bitmap image = sprite.getFirstFrame();
		parachuteMask = new Rect(0, 0, image.getWidth(), parachuteBottom);
		bodyMask = new Rect(0, parachuteBottom, image.getWidth(),
				image.getHeight());
	}

	@Override
	protected void die() {
		deadTimer = Utils.setTimer(model,
				C.Enemies.Paratroopers.Infantry.DEAD_TIMER_NAME);
		setSprite(sprites
				.get(C.Enemies.Paratroopers.Infantry.DIE_SPRITE_INDEX));
		resetAnimation(C.Enemies.Paratroopers.Infantry.ANIMATION_SPEED);
		super.die();
	}
	

	@Override
	protected void land() {
		super.land();
		if(direction == C.InGame.DIRECTION_LEFT)
			setSprite(sprites
				.get(C.Enemies.Paratroopers.Infantry.SHOOTING_LEFT_SPRITE_INDEX));
		else setSprite(sprites
				.get(C.Enemies.Paratroopers.Infantry.SHOOTING_RIGHT_SPRITE_INDEX));
	}

}
